// closure to avoid namespace collision
(function(){
	// creates the plugin
	tinymce.create('tinymce.plugins.mytruedelay', {
		init : function(ed, url) {
			
			// Register commands
			ed.addCommand('videofreakbutton', function() {
				ed.windowManager.open({
					file : url + '/popup.php', // file that contains HTML for our modal window
					width : 770 + parseInt(ed.getLang('button.delta_width', 0)), // size of our window
					height : 600 + parseInt(ed.getLang('button.delta_height', 0)), // size of our window
					inline : 1
				}, {
					plugin_url : url
				});
			});
			 
			// Register buttons
			ed.addButton('mytruedelay_button', {title : 'Insert Vid Button', cmd : 'videofreakbutton', image: url+'/images/favicon.png' });
		},		
	/*
		// creates control instances based on the control's id.
		// our button's id is "mytruedelay_button"
		createControl : function(id, controlManager) {
			if (id == 'mytruedelay_button') {
				// creates the button
				var button = controlManager.createButton('mytruedelay_button', {
					title : 'MyTrueDelay Shortcode', // title of the button
					image : 'https://s3.amazonaws.com/marcus-files/td-shortcode-icon.gif',  // path to the button's image
					onclick : function() {
						// triggers the thickbox
						var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
						W = W - 80;
						H = H - 115;
						tb_show( 'TrueDelay Shortcode', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=mytruedelay-form' );		
					}
				});
				return button;
			}
			return null;
		},
	*/	
		getInfo : function() {
			return {
				longname : 'Insert Vid Button',
				author : 'Marcus Lim',
				authorurl : 'http://www.videomarketingstuff.com',
				infourl : 'http://www.videomarketingstuff.com',
				version : tinymce.majorVersion + "." + tinymce.minorVersion
			};
		}
		
	});
	
	// registers the plugin. DON'T MISS THIS STEP!!!
	tinymce.PluginManager.add('mytruedelay', tinymce.plugins.mytruedelay); 
})();
